package com.deyuanyun.pic.ctrl.controller.vo.exinsp;

import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.ctrl.domain.ExinspCptestStation;
import com.deyuanyun.pic.ctrl.enumeration.*;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;

/**
 * 测试桩检测数据 视图对象
 *
 * @author huanglw
 * @date  2016-9-6
 *
 * History: [修改人][时间][修改描述]
 */
public class ExinspCptestStationVO extends ExinspBaseVO<ExinspCptestStation> {
    // 管道名称
    private String pipeLineName;
    // 测试桩编号
    private String testStationNum;
    // 自然电位
    public Long freeCorrosionPotential;
    // 通电_最大值
    public Long onPotentialMax;
    // 通电_最小值
    public Long onPotentialMin;
    // 通电_平均值
    public Long onPotentialAvg;
    // 断电_最大值
    public Long offPotentialMax;
    // 断电_最小值
    public Long offPotentialMin;
    // 断电_平均值
    public Long offPotentialAvg;
    // 交流电压（V）
    private BigDecimal acInterferenceVoltage;
    // 土壤电阻率（Ω﹒m）
    private BigDecimal soilResistivity;
    // 交流电流密度（A/m2）
    private BigDecimal acCurrentDensity;
    // 交流干扰程度（强中弱）
    private String degreeOfAcInterference;
    // 直流干扰（有、无）
    private String dcInterference;
    // 土壤腐蚀等级（强中弱）
    private String soilCorrosionGrade;
    // 阴保有效性评价(欠/过/有效)
    private String protectingState;
    // 测试桩完好情况（完好、损坏可用、损坏 不可用、缺失）
    private String testStationFineStatus;
    // 检测日期
    private String testingDate;
    // 检测单位
    private String testingCompany;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getTestStationNum() {
        return testStationNum;
    }

    public void setTestStationNum(String testStationNum) {
        this.testStationNum = testStationNum;
    }

    public Long getFreeCorrosionPotential() {
        return freeCorrosionPotential;
    }

    public void setFreeCorrosionPotential(Long freeCorrosionPotential) {
        this.freeCorrosionPotential = freeCorrosionPotential;
    }

    public Long getOnPotentialMax() {
        return onPotentialMax;
    }

    public void setOnPotentialMax(Long onPotentialMax) {
        this.onPotentialMax = onPotentialMax;
    }

    public Long getOnPotentialMin() {
        return onPotentialMin;
    }

    public void setOnPotentialMin(Long onPotentialMin) {
        this.onPotentialMin = onPotentialMin;
    }

    public Long getOnPotentialAvg() {
        return onPotentialAvg;
    }

    public void setOnPotentialAvg(Long onPotentialAvg) {
        this.onPotentialAvg = onPotentialAvg;
    }

    public Long getOffPotentialMax() {
        return offPotentialMax;
    }

    public void setOffPotentialMax(Long offPotentialMax) {
        this.offPotentialMax = offPotentialMax;
    }

    public Long getOffPotentialMin() {
        return offPotentialMin;
    }

    public void setOffPotentialMin(Long offPotentialMin) {
        this.offPotentialMin = offPotentialMin;
    }

    public Long getOffPotentialAvg() {
        return offPotentialAvg;
    }

    public void setOffPotentialAvg(Long offPotentialAvg) {
        this.offPotentialAvg = offPotentialAvg;
    }

    public BigDecimal getAcInterferenceVoltage() {
        return acInterferenceVoltage;
    }

    public void setAcInterferenceVoltage(BigDecimal acInterferenceVoltage) {
        this.acInterferenceVoltage = acInterferenceVoltage;
    }

    public BigDecimal getSoilResistivity() {
        return soilResistivity;
    }

    public void setSoilResistivity(BigDecimal soilResistivity) {
        this.soilResistivity = soilResistivity;
    }

    public BigDecimal getAcCurrentDensity() {
        return acCurrentDensity;
    }

    public void setAcCurrentDensity(BigDecimal acCurrentDensity) {
        this.acCurrentDensity = acCurrentDensity;
    }

    public String getDegreeOfAcInterference() {
        return degreeOfAcInterference;
    }

    public void setDegreeOfAcInterference(String degreeOfAcInterference) {
        this.degreeOfAcInterference = degreeOfAcInterference;
    }

    public String getDcInterference() {
        return dcInterference;
    }

    public void setDcInterference(String dcInterference) {
        this.dcInterference = dcInterference;
    }

    public String getSoilCorrosionGrade() {
        return soilCorrosionGrade;
    }

    public void setSoilCorrosionGrade(String soilCorrosionGrade) {
        this.soilCorrosionGrade = soilCorrosionGrade;
    }

    public String getProtectingState() {
        return protectingState;
    }

    public void setProtectingState(String protectingState) {
        this.protectingState = protectingState;
    }

    public String getTestStationFineStatus() {
        return testStationFineStatus;
    }

    public void setTestStationFineStatus(String testStationFineStatus) {
        this.testStationFineStatus = testStationFineStatus;
    }

    public String getTestingDate() {
        return testingDate;
    }

    public void setTestingDate(String testingDate) {
        this.testingDate = testingDate;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    public void fromDomain(ExinspCptestStation domain) {

        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 测试桩编号
        this.testStationNum = domain.getTestStationId();
        // 自然电位
        this.freeCorrosionPotential = domain.getFreeCorrosionPotential();
        // 通电_最大值
        this.onPotentialMax = domain.getOnPotentialMax();
        // 通电_最小值
        this.onPotentialMin = domain.getOnPotentialMin();
        // 通电_平均值
        this.onPotentialAvg = domain.getOnPotentialAvg();
        // 断电_最大值
        this.offPotentialMax = domain.getOffPotentialMax();
        // 断电_最小值
        this.offPotentialMin = domain.getOffPotentialMin();
        // 断电_平均值
        this.offPotentialAvg = domain.getOffPotentialAvg();
        // 交流电压（V）
        this.acInterferenceVoltage = NumberFormat.formatBigDecimal(domain.getAcInterferenceVoltage());
        // 土壤电阻率（Ω﹒m）
        this.soilResistivity = NumberFormat.formatBigDecimal(domain.getSoilResistivity());
        // 交流电流密度（A/m2）
        this.acCurrentDensity = NumberFormat.formatBigDecimal(domain.getAcCurrentDensity());
        // 交流干扰程度（强中弱）
        this.degreeOfAcInterference = CurrentFerenceEnum.getLabelBycode(domain.getDegreeOfAcInterference());
        // 直流干扰（有、无）
        this.dcInterference = InterferenceSourceEnum.getLabel(domain.getDcInterference());
        // 土壤腐蚀等级（强中弱）
        this.soilCorrosionGrade = CurrentFerenceEnum.getLabelBycode(domain.getSoilCorrosionGrade());
        // 阴保有效性评价(欠/过/有效)
        this.protectingState = CathodicProtectionEvaluationEnum.getLabel(domain.getProtectingState());
        // 测试桩完好情况（完好、损坏可用、损坏 不可用、缺失）
        this.testStationFineStatus = TestStationFineStatusEnum.getLabel(domain.getTestStationFineStatus());
        // 检测日期
        this.testingDate = DateFormat.format(domain.getTestingDate());
        // 检测单位
        this.testingCompany = domain.getTestingCompany();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    public Page<ExinspCptestStationVO> fromDomainList(Page<ExinspCptestStation> domainList) {

        Page<ExinspCptestStationVO> list = new Page<ExinspCptestStationVO>();
        for (ExinspCptestStation exinspCptestStation : domainList) {
            ExinspCptestStationVO exinspCptestStationVO = new ExinspCptestStationVO();
            exinspCptestStationVO.fromDomain(exinspCptestStation);
            list.add(exinspCptestStationVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}